package com.handsome.命令模式;

/**
 * @author niechun
 * @date 2023/3/15 20:21
 */
public class Client {

    public static void main(String[] args) {
        //创建接收者
        LightReceiver lightReceiver = new LightReceiver();
        //创建命令者
        LightOffCommand lightOffCommand = new LightOffCommand(lightReceiver);
        LightOnCommand lightOnCommand = new LightOnCommand(lightReceiver);
        //创建执行者
        RemoteController remoteController = new RemoteController();
        //初始化命令
        remoteController.setCommand(0,lightOnCommand,lightOffCommand);
        remoteController.onButtonPush(0);
        remoteController.cancel();
        remoteController.offButtonPush(0);
        remoteController.cancel();

        //创建接收者
        TelevisionReceiver televisionReceiver=new TelevisionReceiver();
        //创建命令者
        TelevisionOffCommand televisionOffCommand = new TelevisionOffCommand(televisionReceiver);
        TelevisionOnCommand televisionOnCommand = new TelevisionOnCommand(televisionReceiver);
        remoteController.setCommand(1,televisionOnCommand,televisionOffCommand);

        remoteController.onButtonPush(1);
        remoteController.cancel();
        remoteController.offButtonPush(1);
        remoteController.cancel();



    }
}
